var validatorPhone = function(rule, value, callback) {
  if (value === '') {
    callback(new Error('请输入手机号码'))
  } else if (!/^1\d{10}$/.test(value)) {
    callback(new Error('请输入正确的手机号码'))
  } else {
    callback()
  }
}
var validatorBankAccount = function(rule, value, callback) {
  if (value === '') {
    callback(new Error('请输入银行卡账号'))
  } else if (!/^([1-9]{1})(\d{15}|\d{16}|\d{18})$/.test(value)) {
    callback(new Error('请输入正确的银行卡账号'))
  } else {
    callback()
  }
}
var validatoridCard = function(rule, value, callback) {
  const reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
  if (value === '') {
    callback(new Error('请输入证件号'))
  } else if (!reg.test(value)) {
    callback(new Error('请输入正确的证件号'))
  } else {
    callback()
  }
}

const validate = {
  name1: [
    {
      required: true,
      message: '请输入姓名',
      trigger: 'change'
    }
  ],
  name2: [
    {
      required: true,
      message: '请选择性别',
      trigger: 'change'
    }
  ],
  name3: [
    {
      required: true,
      message: '请上传身份证正面',
      trigger: 'change'
    }
  ],
  name4: [
    {
      required: true,
      message: '请上传身份证反面',
      trigger: 'change'
    }
  ],
  name5: [
    {
      required: true,
      trigger: 'change',
      validator: validatoridCard
    }
  ],
  name6: [
    {
      required: true,
      message: '请输入年龄',
      trigger: 'change'
    },
    { type: 'number', message: '请输入数字' }
  ],
  name7: [
    {
      required: true,
      trigger: 'change',
      validator: validatorPhone
    },
    { type: 'number', message: '请输入正确的手机号码' }
  ],
  name8: [
    {
      required: true,
      message: '请选择学历',
      trigger: 'change'
    }
  ],
  name9: [
    {
      required: true,
      trigger: 'change',
      validator: validatorBankAccount
    }
  ],
  name10: [
    {
      required: true,
      message: '请输入开户行',
      trigger: 'change'
    }
  ]
}
export default validate
